function totalFuel = ComplexFuelCalculation()

%REDACTED LOAD OF MAERSK MODULE;%

global n shipID COG
global WaveHeight WaveDir CurrentSpeed CurrentDir WindSpeed WindDir
global draught trim pointIdentifiers WP3D SeaTemp

%The correction is there for the 0 values not to be overlooked in mean.
Correction = WP3D*0.01;
%The last sailing hour for tested route
upperTime = ceil(pointIdentifiers(n+2, 4));

%Preallocating the logged avg. directions and magnitudes for each sailing
%hour
WavePow = zeros(upperTimne, 1);
WindPow = zeros(upperTime, 1);
CurrentEffectiveSpeed = zeros(upperTime, 1);

%Assign SOG for each sailing hour
for k = 2:n+2
    SOG((ceil(pointIdentifiers(k-1, 4))+1):...
        ceil(pointIdentifiers(k, 4))) = pointIdentifiers(k, 3);
end

%Get average relative encountered weather and added power for each sailing
%hour
for i = 1:length(COG)
    %Producing encountered magnitude time layer matrix
    WindSpeedEncounter = WP3D(:, :, i).*WindSpeed(:, :, i) ...
        + Correction(:, :, i);
    WaveHeightEncounter = WP3D(:, :, i).*WaveHeight(:, :, i) ...
        + Correction(:, :, i);
    CurrentSpeedEncounter = WP3D(:, :, i).*CurrentSpeed(:, :, i) ...
        + Correction(:, :, i);
    WindDirEncounter = WP3D(:, :, i).*WindDir(:, :, i) + Correction(:, :, i);
    WaveDirEncounter = WP3D(:, :, i).*WaveDir(:, :, i) + Correction(:, :, i);
    CurrentDirEncounter = WP3D(:, :, i).*CurrentDir(:, :, i) ...
        + Correction(:, :, i);
    
    %Mean Wave Height, Wind Speed and Current Speed for time layer
end
